package com.ruyuan2020.im.design.DecoratorPattern;

// 装饰器抽象类，也实现了Beverage接口，用于装饰其他Beverage对象
public abstract class BeverageDecorator implements Beverage {
    protected Beverage beverage; // 被装饰的饮品对象

    // 通过构造函数传递被装饰的对象
    public BeverageDecorator(Beverage beverage) {
        this.beverage = beverage;
    }

    // 实现接口的getDescription方法，委托给被装饰的对象
    @Override
    public String getDescription() {
        return beverage.getDescription();
    }

    // 实现接口的cost方法，委托给被装饰的对象
    @Override
    public double cost() {
        return beverage.cost();
    }
}


